//	ID : pallab81
// 	PROG : 10325
// 	LANG : C++
// 	2011-06-15-17.35.00 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define SZ(X) (int)(X).size()
#define mk make_pair
#define f first
#define s second

int N,M;
int m_value[20];
map< int,int > st;

inline void read() {
    scanf("%d",&M);
    fo(i,0,M) {
        scanf("%d",&m_value[i]);
    }
}
inline int gcd(int a, int b) {
    while( b ) {
        a%=b;
        swap(a,b);
    }
    return a;
}
inline int lcm(int a, int b) {
    return (a*b)/gcd(a,b);
}

inline void allLCM() {
    int MX = (1<<M);
    st.clear();
    for(int i=1; i<MX; ++i){
            int lcm_ = 1;
            int tot_ = 0;
            for(int j=0; j<M; ++j){
                if( ( i&(1<<j) )!=0 ){
                        lcm_ = lcm( lcm_, m_value[j] );
                        ++tot_;
                }
            }
        st[ lcm_ ] = tot_;
    }
}
inline int customL(int lo, int d){
    return (lo + abs(lo-d) );
}
inline int customR(int hi, int d){
    return (hi - (hi%d) );
}
inline int howMany(int lo, int hi, int d){
    int l  = customL(lo,d);
    int r  = customR(hi,d) ;
    if( l>r )return 0;
    int dif = (r-l)+1;
    int total = dif/d;
    if( (dif%d)!=0 )++total;
return total;
}
inline void proc() {
    allLCM();
    //cout<<SZ(st)<<"\n";
    int res = 0;
    foit(it,st){
        int d = it->f;
        int t = it->s;
        int divisible = howMany(1,N,d);
        res+= divisible  ;
        if( t>1 ){
            res-= (divisible*t);
        }
        cout<< 1 <<" to " <<N<<" "<<divisible<<" times for "<<d<<" where d appears "<<t<<" times\n";
        cout<<res<<"\n"<<bip;
    }
    cout<<"FINAL : "<<res<<"\n";
}
int main() {
    while( scanf("%d",&N)!=EOF ) {
        read();
        proc();
    }
    return 0;
}

